#!/bin/bash

# 提示用户输入Windows格式的路径
read -rp "请输入Windows格式的完整目录路径（必须以 D:\\ps-workspace 开头）: " win_path

echo "输入路径：" $win_path

# 检查路径是否以 E:\ps-workspace 开头
if [[ ! "$win_path" =~ ^D:\\ps-workspace ]]; then
	echo "错误：路径必须以 D:\\ps-workspace 开头！"
	exit 1
fi

# 转换路径格式
# 1. 移除开头的 E:\ps-workspace
remaining_path=$(echo "$win_path" | sed 's/^D:\\ps-workspace//')
# 2. 将反斜杠替换为正斜杠
remaining_path=$(echo "$remaining_path" | tr '\\' '/')
# 3. 拼接目标路径
full_path="/home/dell/windows_share$remaining_path"

# 构建find命令
find_cmd="find \"$full_path\"/*jpg > input_images.txt"
find_cmd2="find \"$full_path\"/*jpeg >> input_images.txt"

# 显示将要执行的命令
echo "将执行以下命令:"
echo "$find_cmd"

# 执行命令
eval "$find_cmd"
eval "$find_cmd2"

# 统计文件行数
line_count=$(wc -l < input_images.txt)
echo "input_images.txt 中共有 $line_count 行"

# 用户确认
read -p "确认执行 remove-bg-mult.py 吗？(y/n) " confirm
if [[ "$confirm" =~ ^[Yy]$ ]]; then
	    echo "正在执行 python remove-bg-mult.py..."
		python remove-bg-mult.py -s
	else
		echo "已取消执行。"
fi
